from selenium.webdriver.common.by import By

from Base.page_base import PageBase


class PagePay(PageBase):
    def __init__(self, driver):
        super().__init__(driver)
        #点击立即购买
        self.__buy = (By.ID,'com.tpshop.malls:id/buy_tv')
        #提交订单
        self.__tj = (By.ID,'com.tpshop.malls:id/submit_tv')
        #立即支付
        self.__pay = (By.ID,'com.tpshop.malls:id/pay_btn')
        #输入支付密码
        self.__pay_pwd = (By.ID,'com.tpshop.malls:id/pwd_et')
        #点击支付确认
        self.__pay_sure = (By.ID,'com.tpshop.malls:id/sure_tv')
        #查看订单
        self.__order = (By.ID,'com.tpshop.malls:id/check_order_tv')
        #支付结果
        self.__pay_result = (By.XPATH,'//android.widget.TextView[@resource-id="com.tpshop.malls:id/title_tv"]')
    def buy_cart(self,pay_pwd):
        self.base_click(self.__buy)
        self.base_click(self.__tj)
        self.base_click(self.__pay)
        self.base_input(self.__pay_pwd,pay_pwd)
        self.base_click(self.__pay_sure)
        self.base_click(self.__order)
    def get_pay_result(self):
        return self.fd_element(self.__pay_result).text
